//
//  LandmarkContentView.swift
//  codelabs
//
//  Created by 雷雷 on 25/05/2025.
//

import SwiftUI
import SwiftData

struct LandmarkContentView: View {
    @Environment(ModelData.self) var modelData
    @State private var selected:Tab = .featured
    @State private var showingProfile = false
    
    
    enum Tab:String{
        case featured="Feutured"
        case list="Landmark"
    }
    
    
    var body: some View {
        NavigationStack{
            TabView(selection:$selected){
                CategoryHome()
                    .tabItem{
                        Label(Tab.featured.rawValue,systemImage: "star")
                    }
                    .tag(Tab.featured)
                
                LandmarkList()
                    .tabItem{
                        Label(Tab.list.rawValue,systemImage: "list.bullet")
                    }
                    .tag(Tab.list)
            }
            .toolbar{
                Button{
                    showingProfile.toggle()
                }label: {
                    Label("User Profile",systemImage: "person.crop.circle")
                }
            }.sheet(isPresented:$showingProfile){
                ProfileHost()
                    .environment(modelData)
            }
        }
    }
    
}

#Preview {
    LandmarkContentView()
        .environment(ModelData())
}
